package com.wt.service.impl;

import com.wt.dao.WqunCommunityDao;
import com.wt.entity.WqunCommunity;
import com.wt.service.WqunCommunityService;
import com.wt.util.R.R;

import java.util.List;

/**
 * <p>
 * 社区讨论表 服务实现类
 * </p>
 *
 * @author wt
 * @since 2023-09-17
 */

public class WqunCommunityServiceImpl implements WqunCommunityService {

    WqunCommunityDao wqunCommunityDao = new WqunCommunityDao();

    @Override
    public List<WqunCommunity> findAllComment() {
        return wqunCommunityDao.findAllComment();
    }

    @Override
    public boolean save(WqunCommunity wqunCommunity) {
        return wqunCommunityDao.save(wqunCommunity);
    }

    @Override
    public WqunCommunity getLastOne() {
        return wqunCommunityDao.getLastOne().get(0);
    }

    @Override
    public R getById(int id) {
        List<WqunCommunity> getById = wqunCommunityDao.getById(id);

        if(getById != null && getById.size() == 1){
            return R.ok().message("查询成功").data("getById",getById.get(0));
        }
        return R.error().message("查询失败");
    }

    @Override
    public boolean updateById(WqunCommunity wqunCommunity) {
        return wqunCommunityDao.updateById(wqunCommunity);
    }

    @Override
    public int countByUid(String id) {
        return wqunCommunityDao.countByUid(id);
    }
}
